<!DOCTYPE html>



  


<html class="theme-next gemini use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">
<script>
    (function(){
        if(''){
            if (prompt('请输入文章密码') !== ''){
                alert('密码错误');
                history.back();
            }
        }
    })();
</script>

<script src="\js\custom\instantclick.min.js" data-no-instant></script>
   <script data-no-instant>
   InstantClick.on('change', function(isInitialLoad) {
   if (isInitialLoad === false) {
     if (typeof MathJax !== 'undefined') // support MathJax
     MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
     if (typeof prettyPrint !== 'undefined') // support google code prettify
     prettyPrint();
     if (typeof _hmt !== 'undefined')  // support 百度统计
     _hmt.push(['_trackPageview', location.pathname + location.search]);
     if (typeof ga !== 'undefined')  // support google analytics
       ga('send', 'pageview', location.pathname + location.search);
   }
   });
   InstantClick.init();
</script>









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="/blog/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />







<link href="/blog/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/blog/css/main.css?v=5.1.4" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="https://pic.imgdb.cn/item/63cf326e588a5d166c681d4c.webp?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="https://pic.imgdb.cn/item/63cf326e588a5d166c681d4c.webp?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="https://pic.imgdb.cn/item/63cf326e588a5d166c681d4c.webp?v=5.1.4">


  <link rel="mask-icon" href="https://pic.imgdb.cn/item/63cf326e588a5d166c681d4c.webp?v=5.1.4" color="#222">





  <meta name="keywords" content="前端,建站," />





  <link rel="alternate" href="/blog/atom.xml" title="傅说" type="application/atom+xml" />






<meta name="description" content="1.下载并安装Node.js git Node.js安装地址：https:&#x2F;&#x2F;nodejs.org&#x2F;zh-cn&#x2F; Windows系统下的安装地址：https:&#x2F;&#x2F;git-scm.com&#x2F;download&#x2F;windows macOS系统下的安装地址：https:&#x2F;&#x2F;git-scm.com&#x2F;download&#x2F;mac （macOS系统会自带git，版本低一点但也够用了）">
<meta property="og:type" content="article">
<meta property="og:title" content="如何用hexo+github配置一个可以建在分目录下的个人博客（2023版）">
<meta property="og:url" content="https://adonis142857.github.io/blog/2023/01/23/%20%E5%A6%82%E4%BD%95%E7%94%A8hexo+github%E9%85%8D%E7%BD%AE%E4%B8%80%E4%B8%AA%E5%8F%AF%E4%BB%A5%E5%BB%BA%E5%9C%A8%E5%88%86%E7%9B%AE%E5%BD%95%E4%B8%8B%E7%9A%84%E4%B8%AA%E4%BA%BA%E5%8D%9A%E5%AE%A2%EF%BC%882023%E7%89%88%EF%BC%89/index.html">
<meta property="og:site_name" content="傅说">
<meta property="og:description" content="1.下载并安装Node.js git Node.js安装地址：https:&#x2F;&#x2F;nodejs.org&#x2F;zh-cn&#x2F; Windows系统下的安装地址：https:&#x2F;&#x2F;git-scm.com&#x2F;download&#x2F;windows macOS系统下的安装地址：https:&#x2F;&#x2F;git-scm.com&#x2F;download&#x2F;mac （macOS系统会自带git，版本低一点但也够用了）">
<meta property="og:locale">
<meta property="og:image" content="https://pic.imgdb.cn/item/63ce8372588a5d166c5d538b.jpg">
<meta property="og:image" content="https://pic.imgdb.cn/item/63ce8372588a5d166c5d53b5.jpg">
<meta property="og:image" content="https://pic.imgdb.cn/item/63ce8372588a5d166c5d53ed.jpg">
<meta property="og:image" content="https://pic.imgdb.cn/item/63ce8372588a5d166c5d5402.jpg">
<meta property="og:image" content="https://pic.imgdb.cn/item/63ce8372588a5d166c5d541d.jpg">
<meta property="og:image" content="https://pic.imgdb.cn/item/63cfd13f588a5d166caf3d53.jpg">
<meta property="og:image" content="https://pic.imgdb.cn/item/63cfd10e588a5d166caee436.jpg">
<meta property="og:image" content="https://pic.imgdb.cn/item/63cfd185588a5d166cafc827.jpg">
<meta property="og:image" content="https://pic.imgdb.cn/item/63ce87ed588a5d166c6c1dc7.jpg">
<meta property="og:image" content="https://pic.imgdb.cn/item/63ce87ed588a5d166c6c1db2.jpg">
<meta property="og:image" content="https://pic.imgdb.cn/item/63ce87ed588a5d166c6c1d68.jpg">
<meta property="article:published_time" content="2023-01-23T04:06:20.230Z">
<meta property="article:modified_time" content="2023-01-26T04:03:49.581Z">
<meta property="article:author" content="傅怡然">
<meta property="article:tag" content="前端">
<meta property="article:tag" content="建站">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://pic.imgdb.cn/item/63ce8372588a5d166c5d538b.jpg">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '',
    scheme: 'Gemini',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":true,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="https://adonis142857.github.io/blog/2023/01/23/ 如何用hexo+github配置一个可以建在分目录下的个人博客（2023版）/"/>





  <title>如何用hexo+github配置一个可以建在分目录下的个人博客（2023版） | 傅说</title>
  





  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?e171d1a29f5e597dd79c5687947a931a";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>




<meta name="generator" content="Hexo 6.3.0"></head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/blog/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">傅说</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">记录想要去记下的生活</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/blog/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/blog/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/blog/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/blog/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-图书馆">
          <a href="/blog/book/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-book"></i> <br />
            
            图书馆
          </a>
        </li>
      
        
        <li class="menu-item menu-item-相册">
          <a href="/blog/gallery/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-photo"></i> <br />
            
            相册
          </a>
        </li>
      
        
        <li class="menu-item menu-item-commonweal">
          <a href="/blog/404/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-bolt"></i> <br />
            
            404
          </a>
        </li>
      

      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br />
            
            搜索
          </a>
        </li>
      
    </ul>
  

  
    <div class="site-search">
      
  <div class="popup search-popup local-search-popup">
  <div class="local-search-header clearfix">
    <span class="search-icon">
      <i class="fa fa-search"></i>
    </span>
    <span class="popup-btn-close">
      <i class="fa fa-times-circle"></i>
    </span>
    <div class="local-search-input-wrapper">
      <input autocomplete="off"
             placeholder="搜索..." spellcheck="false"
             type="text" id="local-search-input">
    </div>
  </div>
  <div id="local-search-result"></div>
</div>



    </div>
  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://adonis142857.github.io/blog/blog/2023/01/23/%20%E5%A6%82%E4%BD%95%E7%94%A8hexo+github%E9%85%8D%E7%BD%AE%E4%B8%80%E4%B8%AA%E5%8F%AF%E4%BB%A5%E5%BB%BA%E5%9C%A8%E5%88%86%E7%9B%AE%E5%BD%95%E4%B8%8B%E7%9A%84%E4%B8%AA%E4%BA%BA%E5%8D%9A%E5%AE%A2%EF%BC%882023%E7%89%88%EF%BC%89/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="https://pic.imgdb.cn/item/63ce893a588a5d166c6ed8de.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="傅说">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">如何用hexo+github配置一个可以建在分目录下的个人博客（2023版）</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2023-01-23T12:06:20+08:00">
                2023-01-23
              </time>
            

            
              <span class="post-meta-divider">|</span>
            

            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-check-o"></i>
              </span>
              
                <span class="post-meta-item-text">更新于&#58;</span>
              
              <time title="更新于" itemprop="dateModified" datetime="2023-01-26T12:03:49+08:00">
                2023-01-26
              </time>
            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/%E5%BB%BA%E7%AB%99/" itemprop="url" rel="index">
                    <span itemprop="name">建站</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/blog/2023/01/23/%20%E5%A6%82%E4%BD%95%E7%94%A8hexo+github%E9%85%8D%E7%BD%AE%E4%B8%80%E4%B8%AA%E5%8F%AF%E4%BB%A5%E5%BB%BA%E5%9C%A8%E5%88%86%E7%9B%AE%E5%BD%95%E4%B8%8B%E7%9A%84%E4%B8%AA%E4%BA%BA%E5%8D%9A%E5%AE%A2%EF%BC%882023%E7%89%88%EF%BC%89/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count valine-comment-count" data-xid="/blog/2023/01/23/%20%E5%A6%82%E4%BD%95%E7%94%A8hexo+github%E9%85%8D%E7%BD%AE%E4%B8%80%E4%B8%AA%E5%8F%AF%E4%BB%A5%E5%BB%BA%E5%9C%A8%E5%88%86%E7%9B%AE%E5%BD%95%E4%B8%8B%E7%9A%84%E4%B8%AA%E4%BA%BA%E5%8D%9A%E5%AE%A2%EF%BC%882023%E7%89%88%EF%BC%89/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          

          
            <span class="post-meta-divider">|</span>
            <span class="page-pv"><i class="fa fa-file-o"></i> 阅读
            <span class="busuanzi-value" id="busuanzi_value_page_pv" ></span>次
            </span>
          

          
            <div class="post-wordcount">
              
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数统计&#58;</span>
                
                <span title="字数统计">
                  966
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                
                <span title="阅读时长">
                  4
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>1.下载并安装Node.js git<br>
Node.js安装地址：<a target="_blank" rel="noopener" href="https://nodejs.org/zh-cn/">https://nodejs.org/zh-cn/</a><br>
Windows系统下的安装地址：<a target="_blank" rel="noopener" href="https://git-scm.com/download/windows">https://git-scm.com/download/windows</a><br>
macOS系统下的安装地址：<a target="_blank" rel="noopener" href="https://git-scm.com/download/mac">https://git-scm.com/download/mac</a><br>
（macOS系统会自带git，版本低一点但也够用了）<span id="more"></span><br>
在cmd/终端中进行指令输入<br>
用node -v来检测Node.js是否安装成功<br>
返回：<br>
<code>v18.13.0</code><br>
用git --version来检测git是否安装成功<br>
返回：<br>
<code>git version 2.37.1 (Apple Git-137.1)</code><br>
2.生成SSH密钥<br>
输入指令<br>
<code>ssh-keygen -t rsa -C &quot;user@email.com&quot;</code>（这里换成你注册github的邮箱）<br>
返回：<br>
Generating public/private rsa key pair.<br>
Enter file in which to save the key (/Users/Adonis142857/.ssh/id_rsa):<br>
Created directory ‘/Users/Adonis142857/.ssh’.<br>
接下来的passphrase可以直接留空<br>
Enter passphrase (empty for no passphrase):<br>
Enter same passphrase again:<br>
Your identification has been saved in /Users/Adonis142857/.ssh/id_rsa<br>
Your public key has been saved in /Users/Adonis142857/.ssh/id_rsa.pub<br>
The key fingerprint is:<br>
打开上方目录中生成的文件<code>id_rsa.pub</code><br>
Ctrl+a/⌘+a进行全文选中<br>
Ctrl+c/⌘+c进行全文拷贝<br>
3.进入github.com并登录<br>
<img src="https://pic.imgdb.cn/item/63ce8372588a5d166c5d538b.jpg" alt><br>
点击右上角人物头像<br>
<img src="https://pic.imgdb.cn/item/63ce8372588a5d166c5d53b5.jpg" alt><br>
点击Settings<br>
<img src="https://pic.imgdb.cn/item/63ce8372588a5d166c5d53ed.jpg" alt><br>
点击SSH and GPG keys<br>
<img src="https://pic.imgdb.cn/item/63ce8372588a5d166c5d5402.jpg" alt><br>
点击 New SSH key<br>
<img src="https://pic.imgdb.cn/item/63ce8372588a5d166c5d541d.jpg" alt><br>
在Title中输入你的github用户名，Key中输入刚才在<code>id_rsa.pub</code>中复制到的字符串<br>
4.安装hexo<br>
依赖安装慢点可以使用镜像<br>
指令如下<br>
清空代理<br>
<code>npm config set proxy null</code><br>
清理缓存<br>
<code>npm cache clean --force</code><br>
重新设置镜像源<br>
<code>npm config set registry https://registry.npm.taobao.org</code><br>
用指令cd进入要安装hexo的目录<br>
<code>例：cd/Users/Adonis142857/Documents/website/blog</code><br>
使用指令<br>
<code>sudo npm install hexo-cli -g</code><br>
安装完后使用指令<br>
<code>hexo init blog</code><br>
安装完后进入目录<br>
<code>cd blog</code><br>
使用指令安装依赖<br>
<code>npminstall</code><br>
安装完后可以使用指令<br>
<code>hexo s</code><br>
在本地页面上查看效果<br>
在浏览器中进入地址localhost:4000即可查看博客界面<br>
5.创建用于储存博客的储存库<br>
<a target="_blank" rel="noopener" href="http://xn--github-2l2js25yfoixu5b.com">进入网站github.com</a><br>
<img src="https://pic.imgdb.cn/item/63cfd13f588a5d166caf3d53.jpg" alt><br>
点击New<br>
<img src="https://pic.imgdb.cn/item/63cfd10e588a5d166caee436.jpg" alt><br>
在其中配置Repository name<br>
这里分两种<br>
(1)希望在username.github.io打开自己博客<br>
那么就在Repository <a target="_blank" rel="noopener" href="http://xn--nameusername-894si79ajxz.github.io">name中填写username.github.io</a>（要换成自己的github用户名）<br>
例：<br>
希望在Adonis142857.github.io打开自己博客<br>
那么就在Repository <a target="_blank" rel="noopener" href="http://xn--nameAdonis142857-t79ys46b2r4a.github.io">name中填写Adonis142857.github.io</a><br>
(2)<a target="_blank" rel="noopener" href="http://xn--username-q86nh56c3px.github.io/Repository">希望在username.github.io/Repository</a> name中打开自己博客（即建在分目录的博客）<br>
那么就在Repository name中填写自己想要建的分目录名称<br>
例：<br>
<a target="_blank" rel="noopener" href="http://xn--Adonis142857-1o9ul26e474a.github.io/blog%E4%B8%AD%E6%89%93%E5%BC%80%E8%87%AA%E5%B7%B1%E5%8D%9A%E5%AE%A2">希望在Adonis142857.github.io/blog中打开自己博客</a><br>
那么就在Repository name中填写blog<br>
<img src="https://pic.imgdb.cn/item/63cfd185588a5d166cafc827.jpg" alt><br>
配置完后点击Create repository<br>
6.将hexo界面发布到github上<br>
打开blog文件夹下的<em>config.yml文件</em><br>
改三个地方<br>
<img src="https://pic.imgdb.cn/item/63ce87ed588a5d166c6c1dc7.jpg" alt><br>
更改title language author<br>
<img src="https://pic.imgdb.cn/item/63ce87ed588a5d166c6c1db2.jpg" alt><br>
改动url：<br>
分两种情况<br>
(1)希望在username.github.io打开自己博客<br>
那么就改成url:  <a target="_blank" rel="noopener" href="https://username.github.io">https://username.github.io</a><br>
例：<br>
url:  <a href="https://Adonis142857.github.io">https://Adonis142857.github.io</a><br>
(2)<a target="_blank" rel="noopener" href="http://xn--username-q86nh56c3px.github.io/Repository">希望在username.github.io/Repository</a> name中打开自己博客（即建在分目录的博客）<br>
那么就改成url: <a target="_blank" rel="noopener" href="https://username.github.io/Repository">https://username.github.io/Repository</a> name<br>
例：<br>
url: <a href="https://Adonis142857.github.io/blog">https://Adonis142857.github.io/blog</a><br>
<img src="https://pic.imgdb.cn/item/63ce87ed588a5d166c6c1d68.jpg" alt><br>
这里type和branch按照图片进行填写就可以<br>
repo还是要分两种情况进行改动<br>
(1)希望在username.github.io打开自己博客<br>
那么就改成repo: <a href="mailto:git@github.com">git@github.com</a>:username/username.github.io.git<br>
例：<br>
repo: <a href="mailto:git@github.com">git@github.com</a>:Adonis142857/Adonis142857.github.io.git<br>
(2)<a target="_blank" rel="noopener" href="http://xn--username-q86nh56c3px.github.io/Repository">希望在username.github.io/Repository</a> name中打开自己博客（即建在分目录的博客）<br>
那么就改成repo: <a href="mailto:git@github.com">git@github.com</a>:username/Repository name.git<br>
例：<br>
repo: <a href="mailto:git@github.com">git@github.com</a>:Adonis142857/blog.git<br>
修改完成后用Ctrl+s/⌘+s进行保存<br>
使用指令安装插件<br>
<code>npm install hexo-deployer-git --save</code><br>
使用指令配置git的邮箱和用户名<br>
<code>git config --global user.email &quot;user@email.com&quot;</code><br>
<code>git config --global user.name &quot;username&quot;</code><br>
（都要改成自己的邮箱和用户名哦）<br>
接下来输入三个指令<br>
<code>hexo clean</code><br>
<code>hexo generate</code><br>
<code>hexo deploy</code><br>
然后你的博客就已经被成功推送到github上了<br>
可以去看看哦</p>

      
    </div>
    
    
    

    

    
      <div>
        <div style="padding: 10px 0; margin: 20px auto; width: 90%; text-align: center;">
  <div>Buy me a coffee</div>
  <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
    <span>打赏</span>
  </button>
  <div id="QR" style="display: none;">

    
      <div id="wechat" style="display: inline-block">
        <img id="wechat_qr" src="https://pic.imgdb.cn/item/63cf2d63588a5d166c617f97.jpg" alt=" 微信支付"/>
        <p>微信支付</p>
      </div>
    

    
      <div id="alipay" style="display: inline-block">
        <img id="alipay_qr" src="https://pic.imgdb.cn/item/63cf2d75588a5d166c6195e6.jpg" alt=" 支付宝"/>
        <p>支付宝</p>
      </div>
    

    

  </div>
</div>

      </div>
    

    
      <div>
        <ul class="post-copyright">
  <li class="post-copyright-author">
    <strong>本文作者：</strong>
    傅怡然
  </li>
  <li class="post-copyright-link">
    <strong>本文链接：</strong>
    <a href="https://adonis142857.github.io/blog/2023/01/23/%20%E5%A6%82%E4%BD%95%E7%94%A8hexo+github%E9%85%8D%E7%BD%AE%E4%B8%80%E4%B8%AA%E5%8F%AF%E4%BB%A5%E5%BB%BA%E5%9C%A8%E5%88%86%E7%9B%AE%E5%BD%95%E4%B8%8B%E7%9A%84%E4%B8%AA%E4%BA%BA%E5%8D%9A%E5%AE%A2%EF%BC%882023%E7%89%88%EF%BC%89/" title="如何用hexo+github配置一个可以建在分目录下的个人博客（2023版）">https://adonis142857.github.io/blog/2023/01/23/%20%E5%A6%82%E4%BD%95%E7%94%A8hexo+github%E9%85%8D%E7%BD%AE%E4%B8%80%E4%B8%AA%E5%8F%AF%E4%BB%A5%E5%BB%BA%E5%9C%A8%E5%88%86%E7%9B%AE%E5%BD%95%E4%B8%8B%E7%9A%84%E4%B8%AA%E4%BA%BA%E5%8D%9A%E5%AE%A2%EF%BC%882023%E7%89%88%EF%BC%89/</a>
  </li>
  <li class="post-copyright-license">
    <strong>版权声明： </strong>
    本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" rel="external nofollow" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明出处！
  </li>
</ul>

      </div>
    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/blog/tags/%E5%89%8D%E7%AB%AF/" rel="tag"># 前端</a>
          
            <a href="/blog/tags/%E5%BB%BA%E7%AB%99/" rel="tag"># 建站</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/blog/2023/05/02/%E6%89%93%E9%80%A0%E2%80%9C%E6%88%91%E2%80%9D/" rel="prev" title="打造“我”">
                打造“我” <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  
    <div class="comments" id="comments">
    </div>
  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      

      <section class="site-overview-wrap sidebar-panel sidebar-panel-active">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image"
                src="https://pic.imgdb.cn/item/63ce893a588a5d166c6ed8de.jpg"
                alt="" />
            
              <p class="site-author-name" itemprop="name"></p>
              <p class="site-description motion-element" itemprop="description"></p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/blog/">
              
                  <span class="site-state-item-count">2</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/blog/categories/index.html">
                  <span class="site-state-item-count">2</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/blog/tags/index.html">
                  <span class="site-state-item-count">4</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          
            <div class="feed-link motion-element">
              <a href="/blog/atom.xml" rel="alternate">
                <i class="fa fa-rss"></i>
                RSS
              </a>
            </div>
          

          

          
          

          
          

          

        </div>
      </section>

      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2023</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">傅怡然</span>

  
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-area-chart"></i>
    </span>
    
      <span class="post-meta-item-text">Site words total count&#58;</span>
    
    <span title="Site words total count">1.8k</span>
  
</div>







<span id="timeDate">载入天数...</span><span id="times">载入时分秒...</span>
<script>
	var now = new Date(); 
	function createtime() { 
		var grt= new Date("1/23/2023 00:00:00");//此处修改你的建站时间或者网站上线时间 
		now.setTime(now.getTime()+250); 
		days = (now - grt ) / 1000 / 60 / 60 / 24; dnum = Math.floor(days); 
		hours = (now - grt ) / 1000 / 60 / 60 - (24 * dnum); hnum = Math.floor(hours); 
		if(String(hnum).length ==1 ){hnum = "0" + hnum;} minutes = (now - grt ) / 1000 /60 - (24 * 60 * dnum) - (60 * hnum); 
		mnum = Math.floor(minutes); if(String(mnum).length ==1 ){mnum = "0" + mnum;} 
		seconds = (now - grt ) / 1000 - (24 * 60 * 60 * dnum) - (60 * 60 * hnum) - (60 * mnum); 
		snum = Math.round(seconds); if(String(snum).length ==1 ){snum = "0" + snum;} 
		document.getElementById("timeDate").innerHTML = "本站已安全运行 "+dnum+" 天 "; 
		document.getElementById("times").innerHTML = hnum + " 小时 " + mnum + " 分 " + snum + " 秒"; 
	} 
	setInterval("createtime()",250);
</script>
        
<div class="busuanzi-count">
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>

  
    <span class="site-uv">
      <i class="fa fa-user"></i> 访问人数
      <span class="busuanzi-value" id="busuanzi_value_site_uv"></span>
      人次
    </span>
  

  
    <span class="site-pv">
      <i class="fa fa-eye"></i> 总访问量
      <span class="busuanzi-value" id="busuanzi_value_site_pv"></span>
      次
    </span>
  
</div>








        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
          <span id="scrollpercent"><span>0</span>%</span>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/blog/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/blog/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/blog/js/src/motion.js?v=5.1.4"></script>



  
  


  <script type="text/javascript" src="/blog/js/src/affix.js?v=5.1.4"></script>

  <script type="text/javascript" src="/blog/js/src/schemes/pisces.js?v=5.1.4"></script>



  
  <script type="text/javascript" src="/blog/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/blog/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/blog/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  










  <script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
  <script src="//unpkg.com/valine/dist/Valine.min.js"></script>
  
  <script type="text/javascript">
    var GUEST = ['nick','mail','link'];
    var guest = 'nick,mail,link';
    guest = guest.split(',').filter(item=>{
      return GUEST.indexOf(item)>-1;
    });
    new Valine({
        el: '#comments' ,
        verify: false,
        notify: false,
        appId: 'gTGXRSh6eB2JR2aLQgFbbNhF-gzGzoHsz',
        appKey: 's3tT3LxhufBnKmXr9K54OMgs',
        placeholder: 'Just go go',
        avatar:'mm',
        guest_info:guest,
        pageSize:'10' || 10,
    });
  </script>



  

  <script type="text/javascript">
    // Popup Window;
    var isfetched = false;
    var isXml = true;
    // Search DB path;
    var search_path = "search.xml";
    if (search_path.length === 0) {
      search_path = "search.xml";
    } else if (/json$/i.test(search_path)) {
      isXml = false;
    }
    var path = "/blog/" + search_path;
    // monitor main search box;

    var onPopupClose = function (e) {
      $('.popup').hide();
      $('#local-search-input').val('');
      $('.search-result-list').remove();
      $('#no-result').remove();
      $(".local-search-pop-overlay").remove();
      $('body').css('overflow', '');
    }

    function proceedsearch() {
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay"></div>')
        .css('overflow', 'hidden');
      $('.search-popup-overlay').click(onPopupClose);
      $('.popup').toggle();
      var $localSearchInput = $('#local-search-input');
      $localSearchInput.attr("autocapitalize", "none");
      $localSearchInput.attr("autocorrect", "off");
      $localSearchInput.focus();
    }

    // search function;
    var searchFunc = function(path, search_id, content_id) {
      'use strict';

      // start loading animation
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay">' +
          '<div id="search-loading-icon">' +
          '<i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>' +
          '</div>' +
          '</div>')
        .css('overflow', 'hidden');
      $("#search-loading-icon").css('margin', '20% auto 0 auto').css('text-align', 'center');

      $.ajax({
        url: path,
        dataType: isXml ? "xml" : "json",
        async: true,
        success: function(res) {
          // get the contents from search data
          isfetched = true;
          $('.popup').detach().appendTo('.header-inner');
          var datas = isXml ? $("entry", res).map(function() {
            return {
              title: $("title", this).text(),
              content: $("content",this).text(),
              url: $("url" , this).text()
            };
          }).get() : res;
          var input = document.getElementById(search_id);
          var resultContent = document.getElementById(content_id);
          var inputEventFunction = function() {
            var searchText = input.value.trim().toLowerCase();
            var keywords = searchText.split(/[\s\-]+/);
            if (keywords.length > 1) {
              keywords.push(searchText);
            }
            var resultItems = [];
            if (searchText.length > 0) {
              // perform local searching
              datas.forEach(function(data) {
                var isMatch = false;
                var hitCount = 0;
                var searchTextCount = 0;
                var title = data.title.trim();
                var titleInLowerCase = title.toLowerCase();
                var content = data.content.trim().replace(/<[^>]+>/g,"");
                var contentInLowerCase = content.toLowerCase();
                var articleUrl = decodeURIComponent(data.url);
                var indexOfTitle = [];
                var indexOfContent = [];
                // only match articles with not empty titles
                if(title != '') {
                  keywords.forEach(function(keyword) {
                    function getIndexByWord(word, text, caseSensitive) {
                      var wordLen = word.length;
                      if (wordLen === 0) {
                        return [];
                      }
                      var startPosition = 0, position = [], index = [];
                      if (!caseSensitive) {
                        text = text.toLowerCase();
                        word = word.toLowerCase();
                      }
                      while ((position = text.indexOf(word, startPosition)) > -1) {
                        index.push({position: position, word: word});
                        startPosition = position + wordLen;
                      }
                      return index;
                    }

                    indexOfTitle = indexOfTitle.concat(getIndexByWord(keyword, titleInLowerCase, false));
                    indexOfContent = indexOfContent.concat(getIndexByWord(keyword, contentInLowerCase, false));
                  });
                  if (indexOfTitle.length > 0 || indexOfContent.length > 0) {
                    isMatch = true;
                    hitCount = indexOfTitle.length + indexOfContent.length;
                  }
                }

                // show search results

                if (isMatch) {
                  // sort index by position of keyword

                  [indexOfTitle, indexOfContent].forEach(function (index) {
                    index.sort(function (itemLeft, itemRight) {
                      if (itemRight.position !== itemLeft.position) {
                        return itemRight.position - itemLeft.position;
                      } else {
                        return itemLeft.word.length - itemRight.word.length;
                      }
                    });
                  });

                  // merge hits into slices

                  function mergeIntoSlice(text, start, end, index) {
                    var item = index[index.length - 1];
                    var position = item.position;
                    var word = item.word;
                    var hits = [];
                    var searchTextCountInSlice = 0;
                    while (position + word.length <= end && index.length != 0) {
                      if (word === searchText) {
                        searchTextCountInSlice++;
                      }
                      hits.push({position: position, length: word.length});
                      var wordEnd = position + word.length;

                      // move to next position of hit

                      index.pop();
                      while (index.length != 0) {
                        item = index[index.length - 1];
                        position = item.position;
                        word = item.word;
                        if (wordEnd > position) {
                          index.pop();
                        } else {
                          break;
                        }
                      }
                    }
                    searchTextCount += searchTextCountInSlice;
                    return {
                      hits: hits,
                      start: start,
                      end: end,
                      searchTextCount: searchTextCountInSlice
                    };
                  }

                  var slicesOfTitle = [];
                  if (indexOfTitle.length != 0) {
                    slicesOfTitle.push(mergeIntoSlice(title, 0, title.length, indexOfTitle));
                  }

                  var slicesOfContent = [];
                  while (indexOfContent.length != 0) {
                    var item = indexOfContent[indexOfContent.length - 1];
                    var position = item.position;
                    var word = item.word;
                    // cut out 100 characters
                    var start = position - 20;
                    var end = position + 80;
                    if(start < 0){
                      start = 0;
                    }
                    if (end < position + word.length) {
                      end = position + word.length;
                    }
                    if(end > content.length){
                      end = content.length;
                    }
                    slicesOfContent.push(mergeIntoSlice(content, start, end, indexOfContent));
                  }

                  // sort slices in content by search text's count and hits' count

                  slicesOfContent.sort(function (sliceLeft, sliceRight) {
                    if (sliceLeft.searchTextCount !== sliceRight.searchTextCount) {
                      return sliceRight.searchTextCount - sliceLeft.searchTextCount;
                    } else if (sliceLeft.hits.length !== sliceRight.hits.length) {
                      return sliceRight.hits.length - sliceLeft.hits.length;
                    } else {
                      return sliceLeft.start - sliceRight.start;
                    }
                  });

                  // select top N slices in content

                  var upperBound = parseInt('1');
                  if (upperBound >= 0) {
                    slicesOfContent = slicesOfContent.slice(0, upperBound);
                  }

                  // highlight title and content

                  function highlightKeyword(text, slice) {
                    var result = '';
                    var prevEnd = slice.start;
                    slice.hits.forEach(function (hit) {
                      result += text.substring(prevEnd, hit.position);
                      var end = hit.position + hit.length;
                      result += '<b class="search-keyword">' + text.substring(hit.position, end) + '</b>';
                      prevEnd = end;
                    });
                    result += text.substring(prevEnd, slice.end);
                    return result;
                  }

                  var resultItem = '';

                  if (slicesOfTitle.length != 0) {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + highlightKeyword(title, slicesOfTitle[0]) + "</a>";
                  } else {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + title + "</a>";
                  }

                  slicesOfContent.forEach(function (slice) {
                    resultItem += "<a href='" + articleUrl + "'>" +
                      "<p class=\"search-result\">" + highlightKeyword(content, slice) +
                      "...</p>" + "</a>";
                  });

                  resultItem += "</li>";
                  resultItems.push({
                    item: resultItem,
                    searchTextCount: searchTextCount,
                    hitCount: hitCount,
                    id: resultItems.length
                  });
                }
              })
            };
            if (keywords.length === 1 && keywords[0] === "") {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-search fa-5x" /></div>'
            } else if (resultItems.length === 0) {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>'
            } else {
              resultItems.sort(function (resultLeft, resultRight) {
                if (resultLeft.searchTextCount !== resultRight.searchTextCount) {
                  return resultRight.searchTextCount - resultLeft.searchTextCount;
                } else if (resultLeft.hitCount !== resultRight.hitCount) {
                  return resultRight.hitCount - resultLeft.hitCount;
                } else {
                  return resultRight.id - resultLeft.id;
                }
              });
              var searchResultList = '<ul class=\"search-result-list\">';
              resultItems.forEach(function (result) {
                searchResultList += result.item;
              })
              searchResultList += "</ul>";
              resultContent.innerHTML = searchResultList;
            }
          }

          if ('auto' === 'auto') {
            input.addEventListener('input', inputEventFunction);
          } else {
            $('.search-icon').click(inputEventFunction);
            input.addEventListener('keypress', function (event) {
              if (event.keyCode === 13) {
                inputEventFunction();
              }
            });
          }

          // remove loading animation
          $(".local-search-pop-overlay").remove();
          $('body').css('overflow', '');

          proceedsearch();
        }
      });
    }

    // handle and trigger popup window;
    $('.popup-trigger').click(function(e) {
      e.stopPropagation();
      if (isfetched === false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };
    });

    $('.popup-btn-close').click(onPopupClose);
    $('.popup').click(function(e){
      e.stopPropagation();
    });
    $(document).on('keyup', function (event) {
      var shouldDismissSearchPopup = event.which === 27 &&
        $('.search-popup').is(':visible');
      if (shouldDismissSearchPopup) {
        onPopupClose();
      }
    });
  </script>





  

  

  

  
  

  
  


  

  

</body>
</html>
